package com.tedu.springboot2307.entity;

import sun.plugin2.message.Serializer;

import java.io.Serializable;

/**
 * 实体类, 该类的每一个实例表示硬盘上的一组数据
 * User类的每一个实例用于表示一个注册用户信息
 *
 */
public class User implements Serializable {

    private String username;
    private String password;
    private String nickname;
    // 建议用包装类, 这样会清晰, 没有歧义. 因为默认值是null,
    // int默认值是0, 当用户输入0, 会发生歧义
    private Integer age;

    /*
        后期框架可以辅助创建实体对象, 通常会使用无参构造器
     */
    public User() {
    }

    public User(String username, String password, String nickname, Integer age) {
        this.username = username;
        this.password = password;
        this.nickname = nickname;
        this.age = age;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getNickname() {
        return nickname;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "User{" +
                "username='" + username + '\'' +
                ", password='" + password + '\'' +
                ", nickname='" + nickname + '\'' +
                ", age=" + age +
                '}';
    }
}
